package com.xmb.common.service.impl;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by lyndon on 2019/3/27.
 */
public class NotifyPayOrderStrategyHolder {

    private static NotifyPayOrderStrategyHolder singleton = null;

    private Map<String, NotifyPayOrderStrategy> strategyMap = null;

    private NotifyPayOrderStrategyHolder() {
        this.strategyMap = new HashMap<>();
    }

    public static synchronized NotifyPayOrderStrategyHolder getSingleton() {
        if (singleton == null) {
            singleton = new NotifyPayOrderStrategyHolder();
        }
        return singleton;
    }

    public void registerStrategy(NotifyPayOrderStrategy strategy) {
        this.strategyMap.put(strategy.getType(), strategy);
    }

    public NotifyPayOrderStrategy getStrategy(String type) {
        return this.strategyMap.get(type);
    }
}
